package com.office.meeting.invited.controller;

import com.office.common.annotation.Log;
import com.office.common.core.controller.BaseController;
import com.office.common.core.domain.AjaxResult;
import com.office.common.core.page.TableDataInfo;
import com.office.common.enums.BusinessType;
import com.office.meeting.invited.pojo.dto.InviteDTO;
import com.office.meeting.invited.pojo.dto.InvitedDTO;
import com.office.meeting.invited.pojo.vo.InviteQueryVO;
import com.office.meeting.invited.service.InviteService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author: 柒月
 * @date: 2025/5/12 下午4:39
 * @version: 1.0
 */
@RestController
@RequestMapping("/conference")
public class InviteController extends BaseController {

    @Resource
    private InviteService inviteService;

    @GetMapping("/all/invite")
    public TableDataInfo invite() {
        startPage();
        List<InviteDTO> list = inviteService.getInviteAllUser();
        return getDataTable(list);
    }

    @GetMapping("/terms/invite")
    public TableDataInfo inviteTerms(InviteQueryVO queryParams) {
        // 分页
        startPage();
        // 根据条件查询被邀请的用户
        List<InviteDTO> list = inviteService.getInviteQueryUser(queryParams);
        return getDataTable(list);
    }

    @DeleteMapping("/del/terms/{ids}")
    @Log(title = "删除会议", businessType = BusinessType.DELETE)
    public AjaxResult delTerms(@PathVariable List<Long> ids) {
        Long number = inviteService.removeTermsByids(ids);
        return AjaxResult.success(number);
    }

    @PostMapping("/add/terms")
    @Log(title = "添加会议", businessType = BusinessType.INSERT)
    public AjaxResult addTerms(@RequestBody InvitedDTO invitedDTO) {
        Long number = inviteService.addTermsAll(invitedDTO);
        return AjaxResult.success(number);
    }
}
